%macro ppp_summary;

	proc printto new log = "&logdir./ppp_summary.txt";
	run;
	
	proc sql;
		connect to odbc as iq
			(dsn = cdwsas_titan uid = gpfrb pwd = &pwd
				insertbuff = 18000 connection = global);
			execute(set temporary option escape_character = on) by iq;
			
			create table ppp as
			select * from connection to iq (
				select 
					a.initial_approval_amt as ppp_amount,
					case when b.score > 0.8 then 1 else 0 end as found
				from covid_sba_ppp_loans as a
					left outer join covid_ppp_250k_fuzzy_match as b
						on(a.loan_num = b.loannumber)
				where a.initial_approval_amt > 250000
			
						
			
		);
	disconnect from iq;
	quit;

	title "Unweighted";
	proc means data = ppp mean;
		var found;
	run;
	
	title "Weighted";
	proc means data = ppp mean;
		var found;
		weight ppp_amount;
	run;
	
	
	proc printto;
	run;


%mend;

